<?php
	header("Content-Type: application/vnd.ms-excel");
	header("Content-Disposition: attachment; filename=\"liste_utilisateurs.xls\"");
?>

<table>
	<caption>Liste des clients</caption>
	<tr>
		<th>Identifiant</th>
		<th>Login</th>
		<th>Nom</th>
		<th>Prenom</th>
		<th>Mail</th>
		<th>Nom d'entreprise</th>
		<th>Adresse</th>
		<th>Ville</th>
		<th>Code postal</th>
		<th>Pays</th>
		<th>Date de naissance</th>
		<th>Date de creation de compte</th>
	</tr>
	<?php
		foreach($users as $u){
			if($u['User']['roles_id'] == 1){
				echo "<tr>";
				echo "<td>" . $u['User']['id'] . "</td>";
				echo "<td>" . $u['User']['username'] . "</td>";
				echo "<td>" . $u['User']['nom'] . "</td>";
				echo "<td>" . $u['User']['prenom'] . "</td>";
				echo "<td>" . $u['User']['mail'] . "</td>";
				echo "<td>" . $u['User']['nom_entreprise'] . "</td>";
				echo "<td>" . $u['User']['adresse'] . "</td>";
				echo "<td>" . $u['User']['ville'] . "</td>";
				echo "<td>" . $u['User']['code_postal'] . "</td>";
				echo "<td>" . $u['User']['pays'] . "</td>";
				echo "<td>" . $u['User']['date_naissance'] . "</td>";
				echo "<td>" . $u['User']['date_create'] . "</td>";
				echo "</tr>";
			}
		}
	?>
</table>

<table></table>
<table></table>
<table></table>

<table>
	<caption>Liste des employes</caption>
	<tr>
		<th>Identifiant</th>
		<th>Login</th>
		<th>Nom</th>
		<th>Prenom</th>
		<th>Mail</th>
		<th>Nom d'entreprise</th>
		<th>Adresse</th>
		<th>Ville</th>
		<th>Code postal</th>
		<th>Pays</th>
		<th>Date de naissance</th>
		<th>Date de creation de compte</th>
	</tr>
	<?php
		foreach($users as $u){
			if($u['User']['roles_id'] == 2){
				echo "<tr>";
				echo "<td>" . $u['User']['id'] . "</td>";
				echo "<td>" . $u['User']['username'] . "</td>";
				echo "<td>" . $u['User']['nom'] . "</td>";
				echo "<td>" . $u['User']['prenom'] . "</td>";
				echo "<td>" . $u['User']['mail'] . "</td>";
				echo "<td>" . $u['User']['nom_entreprise'] . "</td>";
				echo "<td>" . $u['User']['adresse'] . "</td>";
				echo "<td>" . $u['User']['ville'] . "</td>";
				echo "<td>" . $u['User']['code_postal'] . "</td>";
				echo "<td>" . $u['User']['pays'] . "</td>";
				echo "<td>" . $u['User']['date_naissance'] . "</td>";
				echo "<td>" . $u['User']['date_create'] . "</td>";
				echo "</tr>";
			}
		}
	?>
</table>